package com.example.administrator.yuejian_15.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import java.util.List;

public abstract class BaseAdapter<T> extends RecyclerView.Adapter {
    Context context;
    List<T> items;
    int layoutResourse;


    public BaseAdapter(Context context,List<T> items,int layoutResourse){
        this.context = context;
        this.items = items;
        this.layoutResourse = layoutResourse;
    }


    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {

        View itemView= LayoutInflater.from(context).inflate(layoutResourse,parent,false);
        ItemViewHolder itemViewHolder=new ItemViewHolder(itemView);
        return itemViewHolder;
    }


    @Override
    public int getItemCount() {
        if (items.size()==0)
            return 1;
        return items.size();



    }





}
